<template>
  <div>
    <div class="app-head">
      <div class="app-head-inner">
        <router-link :to="{path:'/'}">
          <img class="head-logo" src="../assets/logo.png" alt="">
        </router-link>
        <div class="head-list">
          <ul>
            <li>
              <router-link exact :to="{ path:'/'}">首页</router-link>
            </li>
            <li>
              <router-link :to="{ path:'/other'}">其他</router-link>
            </li>
            <li>
              <router-link :to="{ path:'/about'}"> 关于</router-link>
            </li>
          </ul>
        </div>
        <div class="head-nav">
          <ul class="nav-list">
            <li>{{userName}}</li>
            <li  v-if="userName !== ''"class="nav-pile">|</li>
            <li  v-if="userName !== ''" @click="quit">退出</li>
            <li  v-if="userName === ''" @click="loginClick">登录</li>
            <li  class="nav-pile">|</li>
            <li  v-if="userName === ''" @click="registerClick">注册</li>
            <li class="nav-pile">|</li>
            <li @click="aboutClick">关于</li>
          </ul>
        </div>
      </div>
    </div>
    <div class="app-content">
        <transition :name="transitionName">
          <router-view class="child-view"></router-view>
        </transition>
    </div>
    <div class="app-foot">
      <p>@ 2017 fishenal MIT</p>
    </div>
    <my-dialog :is-show = "isShowAboutDialog" @on-close="closeDialog('isShowAboutDialog')">
      <p>我们旨在赋能企业改变营销、销售和经营的方式。我们为商家、品牌及其他企业提供基本的互联网基础
        设施以及营销平台，让其可借助互联网的力量与用户和客户互动。我们的业务包括核心电商、云计算、
        数字媒体和娱乐以及创新项目和其他业务。我们并通过子公司菜鸟网络及所投资的关联公司口碑，参
        与物流和本地服务行业，同时与蚂蚁金融服务集团有战略合作，该金融服务集团主要通过中国领先的第
        三方网上支付平台支付宝运营。
      </p>
    </my-dialog>
    <my-dialog :is-show = "isShowLoginDialog" @on-close="closeDialog('isShowLoginDialog')">
      <log-form @has-log="onSuccessLog"></log-form>
    </my-dialog>
    <my-dialog :is-show = "isShowRegisterDialog" @on-close="closeDialog('isShowRegisterDialog')">
      <reg-form></reg-form>
    </my-dialog>
  </div>
</template>

<script>
import DiaLog from "./dialog";
import LogForm from './logForm';
import RegForm from './regForm';
export default {
  components: {
    MyDialog: DiaLog,
    LogForm,
    RegForm
  },
  data() {
    return {
      transitionName: "slide-left",
      isShowAboutDialog: false,
      isShowLoginDialog: false,
      isShowRegisterDialog: false,
      userName: ''
    };
  },
  watch: {
    $route(to, from) {
      to.path == "/" ? "slide-right" : "slide-left";
    }
  },
  methods: {
    aboutClick() {
      this.isShowAboutDialog = true;
    },
    loginClick() {
      this.isShowLoginDialog = true;
    },
    registerClick() {
      this.isShowRegisterDialog = true;
    },
    closeDialog(attr) {
      this[attr] = false;
    },
    onSuccessLog(data){
      this.closeDialog(attr);
      this.userName = data.name;
    }
  }
};
</script>
<style>
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  user-select: none;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
  display: block;
}
body {
  line-height: 1;
}
ol,
ul {
  list-style: none;
}
blockquote,
q {
  quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
  content: "";
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
body {
  background: #f0f2f5;
  font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB",
    "Hiragino Sans GB W3", "Microsoft YaHei UI", "Microsoft YaHei",
    "WenQuanYi Micro Hei", sans-serif;
  font-size: 14px;
  color: #444;
}
.child-view {
  transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);
}
.slide-left-enter,
.slide-right-leave-active {
  opacity: 0;
  -webkit-transform: translate(50%, 0);
  transform: translate(50%, 0);
}
.slide-left-leave-active,
.slide-right-enter {
  opacity: 0;
  -webkit-transform: translate(-50%, 0);
  transform: translate(-50%, 0);
}
.app-head {
  background: #e3e4e8;
  color: #b2b2b2;
  height: 90px;
  line-height: 90px;
  width: 100%;
}
.app-head-inner {
  width: 1200px;
  margin: 0 auto;
}
.head-logo {
  float: left;
}
.app-head-inner img {
  width: 50px;
  margin-top: 20px;
}
.head-nav {
  float: right;
}
.head-nav ul {
  overflow: hidden;
}
.head-nav li {
  cursor: pointer;
  float: left;
  color: #000;
}
.head-list li a {
  display: inline-block;
  padding: 0 20px;
}
.active {
  background: #ccc;
}
.head-list {
  float: left;
  width: 800px;
  margin-left: 100px;
  color: #444;
  font-size: 18px;
}
.head-list li {
  cursor: pointer;
  float: left;
}

.nav-pile {
  padding: 0 10px;
}
.app-foot {
  text-align: center;
  height: 80px;
  width: 100%;
  line-height: 80px;
  background: #e3e4e8;
  clear: both;
  margin-top: 30px;
}
.container {
  width: 1200px;
  margin: 0 auto;
}
.hr {
  height: 1px;
  width: 100%;
  background: #ddd;
}
.button {
  background: #4fc08d;
  color: #fff;
  display: inline-block;
  padding: 10px 20px;
  cursor: pointer;
}
.button:hover {
  background: #4fc08d;
}
.g-form {
}
.g-form-line {
  padding: 15px 0;
}
.g-form-label {
  width: 100px;
  font-size: 16px;
  display: inline-block;
}
.g-form-input {
  display: inline-block;
}
.g-form-input input {
  height: 30px;
  width: 200px;
  line-height: 30px;
  vertical-align: middle;
  padding: 0 10px;
  border: 1px solid #ccc;
}
.g-form-btn {
  padding-left: 100px;
}
.g-form-error {
  color: red;
  padding-left: 15px;
}
</style>
